<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>用户管理</title>
	<%@ include file="/WEB-INF/pages/common/frameCommonJs.jsp"  %>
	<style type="text/css">

	</style>
	<script>
		var saveOrUpdateUrl = "<%=request.getContextPath()%>/main!saveUser.action";
		function saveUser(){  
		    $('#fm').form('submit',{  
		        url:saveOrUpdateUrl,  
		        onSubmit: function(){  
		            return $(this).form('validate');  
		        },  
		        success: function(result){  
		            var result = eval('('+result+')');
		            var msg = result.name;
		            if($("#user\\.id").val()!=""){
		            	msg = msg + "修改成功";
		            }else{
		            	msg = msg + "新增成功";
		            }
		            if (result!=''){
		            	$.messager.show({title:"提示信息:",msg:msg,showType:'slide'});
		                $('#dlg').dialog('close');      // close the dialog  
		                $('#userList').datagrid('reload');    // reload the user data  
		            } else {  
		                $.messager.show({  
		                    title: '新增成功',  
		                    msg: result.msg  
		                });  
		            }  
		        }  
		    });  
		}
		
		function toAddUser(){
			$('#dlg').form('clear');
			$('#dlg').dialog('open').dialog('setTitle','新增用户');
		}
		
		function clearData(){
			$('#password').val('');
			$('#rePassword').val('');
		}
		
		jQuery(function(){
			
			jQuery('a[name=update]').click(function(){
				var password = $('#password').val();
				var rePassword = $('#rePassword').val();
				if(password != rePassword){
					$.messager.alert("提示信息","密码不一致!",'warning');
				}else{
					$('#passwordForm').form('submit',{  
				        url:"<%=request.getContextPath()%>/main!updatePassword.action",  
				        onSubmit: function(){  
				            return $(this).form('validate');  
				        },  
				        success: function(result){  
				        	$.messager.show({title:"提示信息:",msg:"修改密码成功!",showType:'slide'});
				        }  
				    });  
					//$.messager.alert("提示信息","修改密码成功!",'slide');
					//$('#passwordForm').submit();
				}
			});
		});
		
		
	</script>
</head>
<body class="easyui-layout" >
	<div region="center" title="用户信息管理" style="overflow:hidden;">
		<br />
		<form id="passwordForm" method="post">
		<table style="font-size:12px; background:#fafafa; padding:10px;" border="0">
			<tr>
				<td align="right">新&nbsp;&nbsp;密&nbsp;&nbsp;码：
				</td>
				<td>
					<input type="password" id="password" name="password" class="easyui-validatebox" value="" />
				</td>
			</tr>
			<tr>
				<td align="right">新密码确认：
				</td>
				<td>
					<input type="password" id="rePassword" name="rePassword" class="easyui-validatebox" value="" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<a href="#" class="easyui-linkbutton" name="update">提交</a>
	 				<a href="#" class="easyui-linkbutton" onclick="clearData()">重置</a>
				</td>
			</tr>
		</table>
		</form>
	</div>

</body>
</html>
